<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Monitoring extends CI_Controller {

    public function index() {
        parent::__construct();
        $this->load->library('ExCRUD');
        $this->load->library('session');
    }

    public function transaksi() {
        $this->load->model('request_transaksi_model');
        $data['list_request'] = $this->request_transaksi_model->getTransaksiTerbaru();
        $this->load->view('header/header_member.php');
        $this->load->view('monitoring/monitoring_transaksi.php', $data);
    }

    public function rekap_transaksi() {
        $this->load->model('request_transaksi_model');
        $data['list_request'] = $this->request_transaksi_model->getTransaksiTerbaru();
        $this->load->view('header/header_member.php');
        $this->load->view('monitoring/rekap_transaksi.php', $data);
    }

    public function get_transaksi_detail($id) {
        if (@strcasecmp('XMLHttpRequest', $_SERVER['HTTP_X_REQUESTED_WITH']) !== 0)
            return;
        $this->load->model('request_transaksi_model');
        $array = $this->request_transaksi_model->get_transaksi_detail($id);
        $data['sukses'] = $data['gagal'] = $data['proses'] = array();
        foreach ($array as $value) {
            if ($value['status'] == 1)
                $data['sukses'] [] = $value['receiver'];
            elseif ($value['status'] == -1)
                $data['gagal'] [] = $value['receiver'];
            else
                $data['proses'] [] = $value['receiver'];
        }
        $html = "<table class=\"table_detail_content\" width=\"90%\"><tbody>"
                . "<tr>"
                . "     <td width=\"10%\">Sukses</td>"
                . "     <td width=\"90%\">: " . count($data['sukses']) . " SMS</td>"
                . "</tr>"
                . "<tr>"
                . "     <td width=\"10%\">Proses</td>"
                . "     <td width=\"90%\">: " . count($data['proses']) . " SMS</td>"
                . "</tr>"
                . "<tr>"
                . "     <td width=\"10%\">Gagal</td>"
                . "     <td width=\"90%\">: " . implode(", ", $data['gagal']) . "</td>"
                . "</tr>"
                . "</tbody></table>";
        echo $html;
    }

}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */